package reflect;

import java.lang.reflect.Method;

/**
 * @Classname: ReflectDemo5
 * @Author: bromide
 * @CreateTime: 2022/4/18--15:13
 * @Version: V1.0
 * @Description: 调用有参方法
 */
public class ReflectDemo5 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();
        //doSomeThing(String)
        Method method = cls.getMethod("doSomeThing", String.class);
        method.invoke(obj, "玩游戏");
        //doSomeThing(String,int)
        method = cls.getMethod("doSomeThing", String.class, int.class);
        method.invoke(obj, "作业", 5);

    }
}
